package com.hqyj.dao;

import com.hqyj.pojo.DayInfo;
import com.hqyj.pojo.ManagerInfo;
import com.hqyj.pojo.UserInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ManagerInfoDao {
    //查询管理员是否存在
    @Select("select * from managerinfo where managerNickName=#{userName}")
    ManagerInfo seByManName(UserInfo user);
    //登录
    @Select("select * from managerinfo where managerNickName=#{userName} and managerPwd=#{userPwd}")
    ManagerInfo login(UserInfo user);

    //查询用户名存在并且取出盐值
    @Select("select * from managerInfo where managerNickName=#{managerNickName}")
    UserInfo selectByName(UserInfo user);

    //分页查询
    @Select("select * from managerInfo")
    List<UserInfo> select();

    //根据userId查询
    @Select("select * from managerInfo where managerId=#{managerId}")
    UserInfo selectByUserId(UserInfo user);

    //修改
    @Update("update managerInfo set managerNickName=#{managerNickName} where managerId=#{managerId}")
    int update(ManagerInfo manager);

    //删除
    @Delete("delete from managerInfo where managerId=#{managerId}")
    int del(UserInfo user);

    //根据编号查询
    @Select("select * from managerInfo where managerId=#{managerId}")
    List<UserInfo> findByUserId(UserInfo user);

    //根据用户名查询
    @Select("select * from managerInfo where managerNickName=#{managerNickName}")
    List<UserInfo> findByUserName(UserInfo user);

    //查询管理员是否存在
    @Select("select count(*) from managerinfo where managerNickName=#{userManager}")
    int seluserManger(UserInfo user);

    //管理员信息查询
    @Select("select * from managerinfo where managerNickName=#{managerNickName} ")
    ManagerInfo selectmag(ManagerInfo mag);

    //查询当前昵称是否存在（重名）
    @Select("select count(*) from managerinfo where managerNickName=#{managerNickName} and managerId!=#{managerId}")
    int selmagName(ManagerInfo mag);

    //修改用户信息
    @Update("update managerinfo set managerNickName=#{managerNickName},managerName=#{managerName},managerSex=#{managerSex},managerBirth=#{managerBirth},managerTel=#{managerTel},managerEmail=#{managerEmail},managerEdu=#{managerEdu},managerIdCard=#{managerIdCard},managerText=#{managerText} where managerId=#{managerId}")
    int updateMagInfo(ManagerInfo mag);

    //根据userId查询
    @Select("select * from managerInfo where managerId=#{managerId}")
    ManagerInfo selectByManagerId(ManagerInfo manager);

    //修改头像
    @Update("update managerInfo set managerPhoto=#{managerPhoto} where managerId=#{managerId}")
    int updateHead(ManagerInfo manager);

    //修改密码
    @Update("update managerInfo set managerPwd=#{managerPwd} where managerId=#{managerId}")
    int updatePwd(ManagerInfo manager);
}
